
class Plugin:

    def __init__(self, config=None) -> None:
        self.config = config
        self.id     = 0
        self.name   = "New Plugin"

        self.flag           = "-p"
        self.full_flag      = "--plugin"
        self.flag_help      = "simple plugin"
        self.flag_action    = ""

    def do_action(self, action, uinput="") -> bool:
        try:
            if uinput in ["", "None", None]:
                result = eval(f'self.{action}()')
            else:
                result = eval(f'self.{action}("{uinput}")')
            return result
        except Exception as e:
            print(f'{self.name} plugin error (do_action): {e}')
            return False

    def get_items(self) -> list:
        return list()

    def to_json(self) -> dict[str, int | str]:
        return {
            "id"    : self.id,
            "name"  : self.name,
        }

    def save_config(self, config) -> None:
        config.add_plugin_option(self.name, "option", "value")

